from brian import *
from brian.library.random_processes import *
from brian.library.synapses import  *
import MoNeuron as Moto
import RNeuron as Renshaw
import InNeuron as IN
from time import clock
from MyConstants import gSynE, gSynI
from matplotlib.backends.backend_pdf import PdfPages
from time import clock
from brian.tools.datamanager import *
from brian.tools.taskfarm import *
from RecurrentInhibition import *
#import cProfile
import objgraph
import gc

def showarraysmem(obj, name=''):
     if isinstance(obj, ndarray):
         size_MB = obj.nbytes/1024.**2
         if size_MB>1.0:
             print name, int(size_MB), 'MB'
     else:
         if hasattr(obj, '__dict__'):
             for x, y in obj.__dict__.iteritems():
                 if len(name):
                     namex = name+'.'+x
                 else:
                     namex = x
                 showarraysmem(y, namex) 
                 
def run():
    
    ri = recurrent_inhibition()
    ri.__call__(-1,8.0,5.0,0.05)
    gc.collect()
    ri.__call__(-1,8.0,5.0,0.05)
    gc.collect()
    ri.__call__(-1,8.0,5.0,0.05)
    objgraph.show_most_common_types(limit=20)
    print 'asdfa'
    
if __name__ == '__main__':
    
    run()
    #cProfile.run('run()')